const {
  GiftShopModel
} = require('../../../../utils/giftshop-model.js');
var giftShopModel = new GiftShopModel();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shopId: '', //门店id
    orderCode: '', //订单号
    orderDetail: {}, //订单详情
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    that.setData({
      shopId: options.shopId, //门店id
      orderCode: options.orderCode, //订单号
    }, function () {
      that.getOrderDetail();
    })
  },

  /**
   * 订单详情
   */
  getOrderDetail() {
    giftShopModel.userOrderDetail({
      merchantId: wx.getStorageSync('merchantId'), //商户ID
      shopId: this.data.shopId, //门店id
      orderCode: this.data.orderCode //订单号
    }).then(data => {
      this.setData({
        orderDetail: data,
      })
    }).catch(err => {
      wx.showToast({
        title: `${err.error}`,
        icon: 'none',
        duration: 2000
      })
    })
  },

  /**
   * 跳到首页
   */
  goHome: function () {
    wx.reLaunch({
      url: '/pages/giftShop/home/index'
    })
  },

   /**
   * 订单详情
   */
  goOrderList() {
    wx.reLaunch({
      url: '/pages/giftShop/myOrder/orderList/index?orderType=2'
    })
  },
})